const argv = process.argv.splice(2);
import log4j from "log4js";
log4j.configure({
    appenders: {
        filelog_modbus: { type: "file", filename: '/var/log/modbustcp.log', },
        filelog_opc: { type: "file", filename: '/var/log/opcserver.log', },
        filelog: { type: "file", filename: '/var/log/dbwriter.log', },
        console: { type: "console" }
    },
    categories: {
        DBWriter: { appenders: ["filelog", "console"], level: "warn", },
        OPC: { appenders: ["filelog_opc", "console"], level: "warn", },
        Modbus: { appenders: ["filelog_modbus", "console"], level: "warn", },
        default: { appenders: ["console"], level: "all" }
    }
})
if (!argv[0]) {
    console.log("未知操作。")
    process.exit();
}
switch (argv[0]) {
    case "opc":
        import("./webopcserver").then(m => {
            m.startServer(log4j);
        })
        break;
    case "modbus":
        import("./modbus").then(m => {
            m.modbus_open(log4j);
        })
        break;
    case "logger":
        import("./logger").then(m => {
            m.logger_open(log4j);
        })
        break;
    case "all":
        import("./webopcserver").then(m => {
            m.startServer(log4j);
        }).then(_ => {
            import("./modbus").then(m => {
                m.modbus_open(log4j);
            })
        }).then(_ => {
            import("./logger").then(m => {
                m.logger_open(log4j);
            })
        })
        break;

}
